/**
 * 
 * @author jsxgr@qq.com
 * 
 */
const { Sequelize } = window.require('sequelize-typescript');
import BaseTable from './base_table';
import Template from './template';
import Project from './project';
import GenDb from './genDb';
import GenTable from './genTable';
import GenTableColumn from './genTableColumn';
import GenCode from './genCode';
import GenCodeMapping from './genCodeMapping';
import TemplateFile from './templateFile';


const sequelize = new Sequelize({

  dialect: 'sqlite',
  operatorsAliases: true, //是否识别字段别名中的下划线
  pool: {
    max: 5,
    min: 0,
    idle: 10000
  },
  define: {
      timestamps: false,
      underscored: true,//下划线
      createdAt: "CreatedAt",  //自定义时间戳
      updatedAt: "UpdatedAt", // 自定义时间戳
  },
  storage: "./config.db",
  //modelPaths: [__dirname + '/ef_models/tables'],

  });

  
sequelize.addModels([Template,Project,GenDb,GenTable,GenTableColumn,GenCode,GenCodeMapping,TemplateFile]) 

  
sequelize.authenticate().then(() => {
console.log('Connection has been established successfully.')
})
.catch((err:any) => {
console.error('Unable to connect to the database:', err)
});

export { sequelize, BaseTable, Template,Project,GenDb,GenTable,GenTableColumn,GenCode,GenCodeMapping,TemplateFile }